package com.lsa.letcode.the112.pathSum;

import static org.junit.Assert.*;

import java.io.IOException;

import org.junit.Test;

import com.lsa.letcode.common.LetCodeTestBase;
import com.lsa.letcode.common.TreeNode;
import com.lsa.letcode.common.TreeUtils;

public class PathSumTest extends LetCodeTestBase {
	@Test
	public void test() throws Exception {
		test("oneNode.tgf", 1, true);
		test("tree1.tgf", 22, true);
		test("tree1.tgf", 27, true);
		test("tree1.tgf", 26, true);
		test("tree1.tgf", 18, true);
		test("tree1.tgf", 9, false);
		test("tree1.tgf", 21, false);
		test("tree1.tgf", 0, false);
	}
	
	private void test(String resName, int sum, boolean hasSum) throws IOException {
		Solution s = new Solution();
		TreeNode n = TreeUtils.fromTgf(this.getClass(), resName);
		assertTrue(hasSum == s.hasPathSum(n, sum));
	}
}
